package com.zzh.partnersys.im.message;

import com.zzh.partnersys.im.message.request.ApplyAddFriendRequestMessage;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
public abstract class Message implements Serializable {

    //获取消息的类�?
    public static Class<?> getMessageClass(int messageType) {
        return messageClasses.get(messageType);
    }

    //序号id
    private int sequenceId;

    //消息类型
    private int messageType;

    public abstract int getMessageType();

    public static final int LoginRequestBindMessage = 0;//登录后，发�?�消息给服务端绑定用户和Channel
    public static final int LoginRequestNotBindMessage = 1;//�?出登录，解绑Channel
    public static final int ApplyAddFriendRequestMessage = 2;//添加好友信息
    public static final int ApplyAddFriendResponseMessage = 3;//添加好友信息(回复)
    public static final int ChatRequestMessage = 4;//私聊信息
    public static final int TeamChatRequestMessage = 5;//群聊信息
    public static final int ChatEmojiRequestMessage = 6;//私聊表情�?
    public static final int TeamChatEmojiRequestMessage = 7;//群聊聊表情包
    public static final int InviteAddTeamRequestMessage = 8;//群聊聊表情包

    private static final Map<Integer, Class<?>> messageClasses = new HashMap<>();

    static {
        messageClasses.put(LoginRequestBindMessage, com.zzh.partnersys.im.message.request.LoginRequestBindMessage.class);
        messageClasses.put(LoginRequestNotBindMessage, com.zzh.partnersys.im.message.request.LoginRequestNotBindMessage.class);
        messageClasses.put(ApplyAddFriendRequestMessage, ApplyAddFriendRequestMessage.class);
        messageClasses.put(ApplyAddFriendResponseMessage, com.zzh.partnersys.im.message.response.ApplyAddFriendResponseMessage.class);
        messageClasses.put(ChatRequestMessage, com.zzh.partnersys.im.message.request.ChatRequestMessage.class);
        messageClasses.put(TeamChatRequestMessage, com.zzh.partnersys.im.message.request.TeamChatRequestMessage.class);
        messageClasses.put(ChatEmojiRequestMessage, com.zzh.partnersys.im.message.request.ChatEmojiRequestMessage.class);
        messageClasses.put(TeamChatEmojiRequestMessage, com.zzh.partnersys.im.message.request.TeamChatEmojiRequestMessage.class);
        messageClasses.put(InviteAddTeamRequestMessage, com.zzh.partnersys.im.message.request.InviteAddTeamRequestMessage.class);
    }
}
